package com.haopt.clock.controller;

import com.haopt.clock.dto.ResultDTO;
import com.haopt.clock.service.ClassificationService;
import com.haopt.clock.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author haopt
 * @version 1.0
 * @ClassName ClassificationController
 * @Description TODO
 * @date 2021/3/19 15:59
 */
@RestController
@RequestMapping("/classification")
public class ClassificationController {
    @Autowired
    private ClassificationService classificationService;

    /**
     * 获取分裂下拉列表
     *
     * @return
     */
    @PostMapping("/list")
    public ResultDTO<List<ResClassificationVO>> list() {
        return classificationService.list();
    }

    /**
     * 分类新增
     *
     * @return
     */
    @PostMapping("/add")
    public ResultDTO<ResIdVO> add(@RequestBody ReqClassificationAddVO vo) {
        return classificationService.add(vo);
    }

    /**
     * 分类编辑
     *
     * @return
     */
    @PostMapping("/update")
    public ResultDTO update(@RequestBody ReqClassificationUpdateVO vo) {
        return classificationService.update(vo);
    }

    /**
     * 分类删除
     *
     * @return
     */
    @PostMapping("/delete")
    public ResultDTO delete(@RequestBody ReqIdVO vo) {
        return classificationService.delete(vo);
    }

    /**
     * 分类详情
     *
     * @return
     */
    @GetMapping("/detail")
    public ResultDTO<ResClassificationDetailVO> detail(@RequestParam("id")String id) {
        return classificationService.detail(id);
    }
}
